package com.echo.echovividlive.service.impl;

import com.echo.echovividlive.common.UserThread;
import com.echo.echovividlive.domain.dto.ReportPageDTO;
import com.echo.echovividlive.domain.entity.Report;
import com.echo.echovividlive.domain.entity.Result;
import com.echo.echovividlive.domain.vo.PageVO;
import com.echo.echovividlive.mapper.ReportMapper;
import com.echo.echovividlive.service.IReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiajunjie
 * @since 2024-10-22
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements IReportService {

    @Resource
    private ReportMapper reportMapper;

    @Override
    public Result pageList(ReportPageDTO pageDTO) {
        PageHelper.startPage(pageDTO.getPageIndex(),pageDTO.getPageSize()==null?10:pageDTO.getPageSize());
        pageDTO.setUserId(UserThread.getUserId());
        Page<Report> pages = reportMapper.pageList(pageDTO);
        return Result.success(new PageVO(pages.getTotal(),pages.getResult()));
    }
}
